I install some packages before i start out analysis.
library(readxl)
library(ggplot2)
library(dplyr)
library(tidyr)
library(lubridate)
library(RColorBrewer)
library(zoo)
library(data.table)
library(plotly)I take four datasets from EVDS. These are: “-House Sales Statistics - Turkey-House Sales Statistics - Mortgaged sales”, “-Housing (TRY)-Weighted Average Interest Rates For Banks Loans”, “-Financial situation of household expectation - Seasonally unadjusted Consumer Confidence Index and Indices of Consumer Tendency Survey Questions”, “-Dollar Exchange Rate”
After receiving the data, i manipulated the data.
## [1] 0
## [1] 0
## Rows: 48
## Columns: 2
## $ Date <date> 2017-04-01, 2017-05-01, 2017-06-01, 2017-07-01, 2017-0...
## $ Expenditure <dbl> 43334, 41738, 35210, 38575, 38743, 40534, 38593, 37250,...
## [1] 0
## [1] 0
## Rows: 48
## Columns: 2
## $ Date <date> 2017-04-01, 2017-05-01, 2017-06-01, 2017-07-01, 2017-08-01, 2...
## $ Rate <dbl> 3.653835, 3.563862, 3.518990, 3.559867, 3.512477, 3.468047, 3....
## [1] 0
## [1] 0
## Rows: 48
## Columns: 2
## $ Date <date> 2017-04-01, 2017-05-01, 2017-06-01, 2017-07-01, 2017-08-0...
## $ Interest <dbl> 11.2750, 11.5450, 11.7200, 12.0150, 12.4900, 12.8680, 13.0...
## [1] 0
## [1] 0
## Rows: 48
## Columns: 3
## $ Date <date> 2017-04-01, 2017-05-01, 2017-06-01, 2017-07-01, 2017-0...
## $ Real <dbl> 83.67062, 85.64057, 85.20785, 86.94195, 86.24911, 85.71...
## $ Expectation <dbl> 90.73988, 91.98471, 89.96299, 91.85820, 91.86267, 89.55...
ggplotly(
ggplot(data=house_sales_new, aes(x=Date, y=Expenditure)) +
geom_line(color="red")+
geom_point()+theme(plot.title = element_text(hjust = 0.5))+
labs(
title = "House Sales Statistics - Turkey - Mortgaged sales",
x = "Date",
y = "Expenditure"
))ggplotly(
ggplot(data=dollar_buying_new, aes(x=Date, y=Rate, group=1)) +
geom_line(color="red")+
geom_point()+theme(plot.title = element_text(hjust = 0.5))+
labs(
title = "Dollar Exchange Rate",
x = "Date",
y = "Rate"
))ggplot(data=household_new, aes(x=Date, y=Expectation, group=1))+
geom_line(color="red")+
geom_point()+theme(plot.title = element_text(hjust = 0.5))+
labs(
title = "Financial Situation of Household Expectation - Survey",
x = "Date",
y = "Interest"
)ggplot(data=household_new, aes(x=Date, y=Real, group=1))+
geom_line(color="red")+
geom_point()+theme(plot.title = element_text(hjust = 0.5))+
labs(
title = "Financial Situation of Household-Survey",
x = "Date",
y = "Real"
)ggplotly(
ggplot(data=housing_interest_new, aes(x=Date, y=Interest, group=1)) +
geom_line(color="red")+
geom_point()+theme(plot.title = element_text(hjust = 0.5))+
labs(
title = "I.R for Bank Loans",
x = "Date",
y = "Interest"
))# sort each with date
house_sales_new<-house_sales_new[order(Date),]
household_new<-household_new[order(Date),]
housing_interest_new<-housing_interest_new[order(Date),]
dollar_buying_new<-dollar_buying_new[order(Date),]# sort each with date
lag.count<-6
take.year.lag<-function(array_){
df<-c()
for (i in 1:lag.count){
df<-cbind(df,lag(array_,n=i))
}
return(df)
}
house_sales_new_lags=take.year.lag(house_sales_new$Expenditure)
lag_col_names=c()
for (i in 1:lag.count){
lag_col_names=append(lag_col_names,paste0("Expenditure_lag_",i))
}
colnames(house_sales_new_lags)=lag_col_names
household_new_lags.Real=take.year.lag(household_new$Real)
lag_col_names=c()
for (i in 1:lag.count){
lag_col_names=append(lag_col_names,paste0("Real_lag_",i))
}
colnames(household_new_lags.Real)=lag_col_names
household_new_lags.Expectation=take.year.lag(household_new$Expectation)
lag_col_names=c()
for (i in 1:lag.count){
lag_col_names=append(lag_col_names,paste0("Expectation_lag_",i))
}
colnames(household_new_lags.Expectation)=lag_col_names
housing_interest_new_lags=take.year.lag(housing_interest_new$Interest)
lag_col_names=c()
for (i in 1:lag.count){
lag_col_names=append(lag_col_names,paste0("Interest_lag_",i))
}
colnames(housing_interest_new_lags)=lag_col_names
dollar_buying_new_lags=take.year.lag(dollar_buying_new$Rate)
lag_col_names=c()
for (i in 1:lag.count){
lag_col_names=append(lag_col_names,paste0("Rate_lag_",i))
}
colnames(dollar_buying_new_lags)=lag_col_nameshouse_sales_main<-cbind(house_sales_new,house_sales_new_lags,household_new_lags.Real,household_new_lags.Expectation,housing_interest_new_lags,dollar_buying_new_lags)
house_sales_main<-na.omit(house_sales_main)
house_sales_main$Year<-as.numeric(format(house_sales_main$Date, format="%Y"))
house_sales_main$Month<-as.numeric(format(house_sales_main$Date, format="%m"))
model<-lm(Expenditure~.-Date,data=house_sales_main)
summary(model)##
## Call:
## lm(formula = Expenditure ~ . - Date, data = house_sales_main)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7978.5 -2282.9 -98.9 2347.9 9506.3
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.351e+07 7.068e+07 1.323 0.2185
## Expenditure_lag_1 8.356e-01 3.430e-01 2.436 0.0376 *
## Expenditure_lag_2 -6.066e-01 4.142e-01 -1.464 0.1771
## Expenditure_lag_3 2.393e-01 4.081e-01 0.586 0.5720
## Expenditure_lag_4 -7.190e-01 3.871e-01 -1.857 0.0962 .
## Expenditure_lag_5 -4.162e-01 4.165e-01 -0.999 0.3438
## Expenditure_lag_6 -1.182e-02 2.942e-01 -0.040 0.9688
## Real_lag_1 -1.376e+03 1.741e+03 -0.790 0.4496
## Real_lag_2 4.573e+03 1.811e+03 2.525 0.0325 *
## Real_lag_3 5.781e+02 2.164e+03 0.267 0.7954
## Real_lag_4 -4.167e+03 2.859e+03 -1.457 0.1790
## Real_lag_5 -4.707e+03 1.768e+03 -2.662 0.0260 *
## Real_lag_6 4.793e+03 1.773e+03 2.703 0.0243 *
## Expectation_lag_1 2.412e+03 1.110e+03 2.173 0.0579 .
## Expectation_lag_2 -3.048e+03 1.115e+03 -2.733 0.0231 *
## Expectation_lag_3 -2.269e+03 1.211e+03 -1.873 0.0939 .
## Expectation_lag_4 -2.167e+01 1.865e+03 -0.012 0.9910
## Expectation_lag_5 2.755e+03 1.512e+03 1.822 0.1018
## Expectation_lag_6 -2.748e+03 1.310e+03 -2.097 0.0654 .
## Interest_lag_1 -2.390e+03 1.925e+03 -1.242 0.2458
## Interest_lag_2 9.913e+02 2.652e+03 0.374 0.7172
## Interest_lag_3 3.701e+03 2.596e+03 1.426 0.1877
## Interest_lag_4 -4.172e+03 2.951e+03 -1.414 0.1910
## Interest_lag_5 -6.374e+03 2.751e+03 -2.317 0.0457 *
## Interest_lag_6 1.189e+03 1.743e+03 0.682 0.5122
## Rate_lag_1 2.524e+04 2.059e+04 1.226 0.2513
## Rate_lag_2 1.528e+04 2.087e+04 0.732 0.4827
## Rate_lag_3 -3.366e+04 2.214e+04 -1.520 0.1628
## Rate_lag_4 -5.507e+02 2.548e+04 -0.022 0.9832
## Rate_lag_5 2.874e+03 2.383e+04 0.121 0.9066
## Rate_lag_6 2.433e+04 1.733e+04 1.404 0.1939
## Year -4.618e+04 3.498e+04 -1.320 0.2194
## Month -3.068e+03 3.349e+03 -0.916 0.3835
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7966 on 9 degrees of freedom
## Multiple R-squared: 0.9778, Adjusted R-squared: 0.899
## F-statistic: 12.4 on 32 and 9 DF, p-value: 0.0002164
final.model<-step(lm(Expenditure~.-Date , data=house_sales_main),direction="backward")## Start: AIC=755.87
## Expenditure ~ (Date + Expenditure_lag_1 + Expenditure_lag_2 +
## Expenditure_lag_3 + Expenditure_lag_4 + Expenditure_lag_5 +
## Expenditure_lag_6 + Real_lag_1 + Real_lag_2 + Real_lag_3 +
## Real_lag_4 + Real_lag_5 + Real_lag_6 + Expectation_lag_1 +
## Expectation_lag_2 + Expectation_lag_3 + Expectation_lag_4 +
## Expectation_lag_5 + Expectation_lag_6 + Interest_lag_1 +
## Interest_lag_2 + Interest_lag_3 + Interest_lag_4 + Interest_lag_5 +
## Interest_lag_6 + Rate_lag_1 + Rate_lag_2 + Rate_lag_3 + Rate_lag_4 +
## Rate_lag_5 + Rate_lag_6 + Year + Month) - Date
##
## Df Sum of Sq RSS AIC
## - Expectation_lag_4 1 8575 571116230 753.87
## - Rate_lag_4 1 29656 571137311 753.87
## - Expenditure_lag_6 1 102514 571210169 753.88
## - Rate_lag_5 1 923231 572030886 753.94
## - Real_lag_3 1 4527097 575634752 754.20
## - Interest_lag_2 1 8869829 579977484 754.51
## - Expenditure_lag_3 1 21822278 592929933 755.44
## <none> 571107655 755.87
## - Interest_lag_6 1 29547300 600654955 755.99
## - Rate_lag_2 1 34014171 605121826 756.30
## - Real_lag_1 1 39642451 610750106 756.69
## - Month 1 53253437 624361092 757.61
## - Expenditure_lag_5 1 63342072 634449727 758.29
## - Rate_lag_1 1 95395698 666503353 760.36
## - Interest_lag_1 1 97815466 668923121 760.51
## - Year 1 110594463 681702118 761.30
## - Rate_lag_6 1 125093162 696200817 762.19
## - Interest_lag_4 1 126858509 697966164 762.29
## - Interest_lag_3 1 128984883 700092539 762.42
## - Real_lag_4 1 134775303 705882958 762.77
## - Expenditure_lag_2 1 136083936 707191591 762.84
## - Rate_lag_3 1 146596673 717704328 763.46
## - Expectation_lag_5 1 210575658 781683313 767.05
## - Expenditure_lag_4 1 218871708 789979363 767.49
## - Expectation_lag_3 1 222561131 793668786 767.69
## - Expectation_lag_6 1 279151630 850259285 770.58
## - Expectation_lag_1 1 299532992 870640647 771.58
## - Interest_lag_5 1 340681597 911789252 773.52
## - Expenditure_lag_1 1 376463782 947571437 775.13
## - Real_lag_2 1 404646737 975754392 776.36
## - Real_lag_5 1 449681396 1020789051 778.26
## - Real_lag_6 1 463581996 1034689651 778.83
## - Expectation_lag_2 1 473925818 1045033473 779.25
##
## Step: AIC=753.87
## Expenditure ~ Expenditure_lag_1 + Expenditure_lag_2 + Expenditure_lag_3 +
## Expenditure_lag_4 + Expenditure_lag_5 + Expenditure_lag_6 +
## Real_lag_1 + Real_lag_2 + Real_lag_3 + Real_lag_4 + Real_lag_5 +
## Real_lag_6 + Expectation_lag_1 + Expectation_lag_2 + Expectation_lag_3 +
## Expectation_lag_5 + Expectation_lag_6 + Interest_lag_1 +
## Interest_lag_2 + Interest_lag_3 + Interest_lag_4 + Interest_lag_5 +
## Interest_lag_6 + Rate_lag_1 + Rate_lag_2 + Rate_lag_3 + Rate_lag_4 +
## Rate_lag_5 + Rate_lag_6 + Year + Month
##
## Df Sum of Sq RSS AIC
## - Rate_lag_4 1 24545 571140775 751.87
## - Expenditure_lag_6 1 93943 571210173 751.88
## - Rate_lag_5 1 1084669 572200899 751.95
## - Real_lag_3 1 5041940 576158169 752.24
## - Interest_lag_2 1 14726253 585842483 752.94
## - Expenditure_lag_3 1 21814399 592930628 753.44
## <none> 571116230 753.87
## - Interest_lag_6 1 30867706 601983936 754.08
## - Rate_lag_2 1 36930799 608047029 754.50
## - Real_lag_1 1 60175158 631291388 756.08
## - Expenditure_lag_5 1 63665534 634781763 756.31
## - Month 1 76611983 647728213 757.16
## - Interest_lag_1 1 102984186 674100416 758.83
## - Rate_lag_1 1 117960770 689077000 759.75
## - Rate_lag_6 1 128889779 700006009 760.42
## - Expenditure_lag_2 1 137852458 708968688 760.95
## - Interest_lag_4 1 138290753 709406982 760.98
## - Interest_lag_3 1 138937952 710054181 761.01
## - Rate_lag_3 1 146592594 717708823 761.46
## - Year 1 147103781 718220010 761.49
## - Expectation_lag_5 1 210859280 781975510 765.07
## - Expenditure_lag_4 1 219922501 791038731 765.55
## - Expectation_lag_3 1 224245467 795361697 765.78
## - Real_lag_4 1 276284689 847400919 768.44
## - Expectation_lag_6 1 312988751 884104981 770.22
## - Expectation_lag_1 1 313552838 884669068 770.25
## - Interest_lag_5 1 351898869 923015098 772.03
## - Real_lag_2 1 410891660 982007890 774.63
## - Real_lag_5 1 450439246 1021555476 776.29
## - Real_lag_6 1 538083479 1109199709 779.75
## - Expectation_lag_2 1 615470780 1186587009 782.58
## - Expenditure_lag_1 1 651743316 1222859545 783.85
##
## Step: AIC=751.87
## Expenditure ~ Expenditure_lag_1 + Expenditure_lag_2 + Expenditure_lag_3 +
## Expenditure_lag_4 + Expenditure_lag_5 + Expenditure_lag_6 +
## Real_lag_1 + Real_lag_2 + Real_lag_3 + Real_lag_4 + Real_lag_5 +
## Real_lag_6 + Expectation_lag_1 + Expectation_lag_2 + Expectation_lag_3 +
## Expectation_lag_5 + Expectation_lag_6 + Interest_lag_1 +
## Interest_lag_2 + Interest_lag_3 + Interest_lag_4 + Interest_lag_5 +
## Interest_lag_6 + Rate_lag_1 + Rate_lag_2 + Rate_lag_3 + Rate_lag_5 +
## Rate_lag_6 + Year + Month
##
## Df Sum of Sq RSS AIC
## - Expenditure_lag_6 1 219382 571360157 749.89
## - Rate_lag_5 1 1582888 572723663 749.99
## - Real_lag_3 1 5081037 576221812 750.24
## - Interest_lag_2 1 16228407 587369182 751.05
## <none> 571140775 751.87
## - Expenditure_lag_3 1 28306679 599447454 751.90
## - Interest_lag_6 1 31868717 603009492 752.15
## - Rate_lag_2 1 52184117 623324892 753.54
## - Real_lag_1 1 66319147 637459922 754.48
## - Month 1 76609469 647750244 755.16
## - Expenditure_lag_5 1 89044638 660185414 755.96
## - Interest_lag_1 1 105602663 676743438 757.00
## - Rate_lag_6 1 132601819 703742595 758.64
## - Year 1 147961088 719101863 759.55
## - Rate_lag_1 1 169904024 741044799 760.81
## - Interest_lag_3 1 170492433 741633208 760.84
## - Expenditure_lag_2 1 181282235 752423010 761.45
## - Interest_lag_4 1 186060554 757201329 761.71
## - Rate_lag_3 1 195136418 766277194 762.21
## - Expectation_lag_5 1 221000699 792141474 763.61
## - Expectation_lag_3 1 242792362 813933138 764.75
## - Expenditure_lag_4 1 250681419 821822194 765.15
## - Expectation_lag_6 1 313037204 884177979 768.22
## - Interest_lag_5 1 366781743 937922518 770.70
## - Expectation_lag_1 1 368100294 939241069 770.76
## - Real_lag_2 1 417189716 988330491 772.90
## - Real_lag_4 1 429221899 1000362674 773.41
## - Real_lag_5 1 450503737 1021644512 774.29
## - Real_lag_6 1 579633838 1150774613 779.29
## - Expectation_lag_2 1 625525107 1196665882 780.94
## - Expenditure_lag_1 1 652104015 1223244790 781.86
##
## Step: AIC=749.89
## Expenditure ~ Expenditure_lag_1 + Expenditure_lag_2 + Expenditure_lag_3 +
## Expenditure_lag_4 + Expenditure_lag_5 + Real_lag_1 + Real_lag_2 +
## Real_lag_3 + Real_lag_4 + Real_lag_5 + Real_lag_6 + Expectation_lag_1 +
## Expectation_lag_2 + Expectation_lag_3 + Expectation_lag_5 +
## Expectation_lag_6 + Interest_lag_1 + Interest_lag_2 + Interest_lag_3 +
## Interest_lag_4 + Interest_lag_5 + Interest_lag_6 + Rate_lag_1 +
## Rate_lag_2 + Rate_lag_3 + Rate_lag_5 + Rate_lag_6 + Year +
## Month
##
## Df Sum of Sq RSS AIC
## - Rate_lag_5 1 1566759 572926916 748.00
## - Real_lag_3 1 4863052 576223209 748.24
## - Interest_lag_2 1 20676194 592036351 749.38
## <none> 571360157 749.89
## - Interest_lag_6 1 37847112 609207269 750.58
## - Expenditure_lag_3 1 39028312 610388470 750.66
## - Rate_lag_2 1 54421830 625781987 751.71
## - Real_lag_1 1 72050653 643410810 752.87
## - Month 1 81032584 652392741 753.46
## - Interest_lag_1 1 105390382 676750539 755.00
## - Rate_lag_6 1 136921916 708282074 756.91
## - Year 1 149557095 720917252 757.65
## - Rate_lag_1 1 170816948 742177105 758.87
## - Interest_lag_3 1 177657272 749017429 759.26
## - Expenditure_lag_5 1 207139313 778499470 760.88
## - Interest_lag_4 1 211512393 782872550 761.11
## - Expectation_lag_5 1 236140413 807500570 762.41
## - Expenditure_lag_2 1 241520654 812880811 762.69
## - Expectation_lag_3 1 273771014 845131171 764.33
## - Rate_lag_3 1 285234627 856594784 764.89
## - Expectation_lag_6 1 326780309 898140466 766.88
## - Interest_lag_5 1 379341113 950701270 769.27
## - Expenditure_lag_4 1 387445882 958806039 769.63
## - Expectation_lag_1 1 400987657 972347814 770.22
## - Real_lag_5 1 456301684 1027661841 772.54
## - Real_lag_4 1 506142113 1077502270 774.53
## - Real_lag_2 1 544269957 1115630114 775.99
## - Expectation_lag_2 1 643091586 1214451743 779.56
## - Expenditure_lag_1 1 651889874 1223250031 779.86
## - Real_lag_6 1 660722351 1232082508 780.16
##
## Step: AIC=748
## Expenditure ~ Expenditure_lag_1 + Expenditure_lag_2 + Expenditure_lag_3 +
## Expenditure_lag_4 + Expenditure_lag_5 + Real_lag_1 + Real_lag_2 +
## Real_lag_3 + Real_lag_4 + Real_lag_5 + Real_lag_6 + Expectation_lag_1 +
## Expectation_lag_2 + Expectation_lag_3 + Expectation_lag_5 +
## Expectation_lag_6 + Interest_lag_1 + Interest_lag_2 + Interest_lag_3 +
## Interest_lag_4 + Interest_lag_5 + Interest_lag_6 + Rate_lag_1 +
## Rate_lag_2 + Rate_lag_3 + Rate_lag_6 + Year + Month
##
## Df Sum of Sq RSS AIC
## - Real_lag_3 1 4244503 577171419 746.31
## - Interest_lag_2 1 21538566 594465481 747.55
## <none> 572926916 748.00
## - Interest_lag_6 1 36466283 609393199 748.59
## - Expenditure_lag_3 1 41278436 614205351 748.92
## - Rate_lag_2 1 53445408 626372324 749.75
## - Real_lag_1 1 71373558 644300474 750.93
## - Month 1 84213113 657140029 751.76
## - Interest_lag_1 1 106412200 679339116 753.16
## - Year 1 158806567 731733482 756.28
## - Interest_lag_3 1 180514440 753441356 757.50
## - Interest_lag_4 1 219843853 792770769 759.64
## - Rate_lag_1 1 229178956 802105872 760.13
## - Expenditure_lag_2 1 240405826 813332742 760.72
## - Expectation_lag_5 1 241451031 814377947 760.77
## - Expectation_lag_3 1 284332859 857259775 762.93
## - Rate_lag_3 1 298471654 871398570 763.61
## - Expenditure_lag_5 1 320147855 893074771 764.65
## - Expectation_lag_6 1 350024878 922951794 766.03
## - Expenditure_lag_4 1 396598667 969525583 768.10
## - Expectation_lag_1 1 423690933 996617848 769.25
## - Rate_lag_6 1 424656169 997583085 769.29
## - Real_lag_5 1 479239626 1052166542 771.53
## - Real_lag_2 1 571074170 1144001085 775.05
## - Interest_lag_5 1 656824155 1229751071 778.08
## - Expectation_lag_2 1 671499601 1244426517 778.58
## - Real_lag_6 1 674360146 1247287062 778.68
## - Expenditure_lag_1 1 718709674 1291636589 780.14
## - Real_lag_4 1 730083573 1303010488 780.51
##
## Step: AIC=746.31
## Expenditure ~ Expenditure_lag_1 + Expenditure_lag_2 + Expenditure_lag_3 +
## Expenditure_lag_4 + Expenditure_lag_5 + Real_lag_1 + Real_lag_2 +
## Real_lag_4 + Real_lag_5 + Real_lag_6 + Expectation_lag_1 +
## Expectation_lag_2 + Expectation_lag_3 + Expectation_lag_5 +
## Expectation_lag_6 + Interest_lag_1 + Interest_lag_2 + Interest_lag_3 +
## Interest_lag_4 + Interest_lag_5 + Interest_lag_6 + Rate_lag_1 +
## Rate_lag_2 + Rate_lag_3 + Rate_lag_6 + Year + Month
##
## Df Sum of Sq RSS AIC
## - Interest_lag_2 1 23966294 601137714 746.02
## <none> 577171419 746.31
## - Interest_lag_6 1 32291430 609462849 746.60
## - Expenditure_lag_3 1 51646374 628817794 747.91
## - Rate_lag_2 1 54260202 631431621 748.08
## - Real_lag_1 1 68794624 645966044 749.04
## - Month 1 101882526 679053945 751.14
## - Interest_lag_1 1 112562221 689733640 751.79
## - Interest_lag_3 1 181636732 758808151 755.80
## - Year 1 204505021 781676440 757.05
## - Expenditure_lag_2 1 258096290 835267709 759.83
## - Interest_lag_4 1 269516051 846687470 760.41
## - Expectation_lag_5 1 274709845 851881264 760.66
## - Expectation_lag_3 1 289612249 866783668 761.39
## - Expenditure_lag_5 1 316309783 893481202 762.66
## - Rate_lag_1 1 320323340 897494759 762.85
## - Rate_lag_3 1 389616816 966788236 765.98
## - Real_lag_5 1 490409812 1067581231 770.14
## - Expectation_lag_1 1 510212550 1087383969 770.91
## - Rate_lag_6 1 546871480 1124042899 772.31
## - Expectation_lag_6 1 572382704 1149554123 773.25
## - Expenditure_lag_4 1 621639355 1198810774 775.01
## - Real_lag_2 1 656647457 1233818876 776.22
## - Interest_lag_5 1 687443706 1264615125 777.26
## - Real_lag_6 1 770433457 1347604876 779.92
## - Real_lag_4 1 830318730 1407490149 781.75
## - Expectation_lag_2 1 851019212 1428190631 782.36
## - Expenditure_lag_1 1 1384525297 1961696716 795.70
##
## Step: AIC=746.02
## Expenditure ~ Expenditure_lag_1 + Expenditure_lag_2 + Expenditure_lag_3 +
## Expenditure_lag_4 + Expenditure_lag_5 + Real_lag_1 + Real_lag_2 +
## Real_lag_4 + Real_lag_5 + Real_lag_6 + Expectation_lag_1 +
## Expectation_lag_2 + Expectation_lag_3 + Expectation_lag_5 +
## Expectation_lag_6 + Interest_lag_1 + Interest_lag_3 + Interest_lag_4 +
## Interest_lag_5 + Interest_lag_6 + Rate_lag_1 + Rate_lag_2 +
## Rate_lag_3 + Rate_lag_6 + Year + Month
##
## Df Sum of Sq RSS AIC
## <none> 601137714 746.02
## - Rate_lag_2 1 37785511 638923225 746.58
## - Interest_lag_6 1 41031779 642169493 746.79
## - Expenditure_lag_3 1 58048032 659185745 747.89
## - Real_lag_1 1 85769465 686907178 749.62
## - Interest_lag_1 1 92346727 693484440 750.02
## - Month 1 101202513 702340226 750.55
## - Year 1 202647481 803785194 756.22
## - Expectation_lag_3 1 273749482 874887195 759.78
## - Expenditure_lag_2 1 292235708 893373422 760.66
## - Expenditure_lag_5 1 305811598 906949311 761.29
## - Interest_lag_4 1 307322886 908460599 761.36
## - Expectation_lag_5 1 325871038 927008752 762.21
## - Rate_lag_1 1 329112034 930249748 762.36
## - Interest_lag_3 1 364599743 965737457 763.93
## - Rate_lag_3 1 365769203 966906916 763.98
## - Real_lag_5 1 510146829 1111284543 769.83
## - Expectation_lag_1 1 533202543 1134340256 770.69
## - Rate_lag_6 1 600639294 1201777008 773.11
## - Expenditure_lag_4 1 663523927 1264661640 775.26
## - Interest_lag_5 1 724831974 1325969687 777.25
## - Expectation_lag_6 1 729135748 1330273462 777.38
## - Real_lag_2 1 789859018 1390996731 779.26
## - Real_lag_6 1 828475702 1429613415 780.41
## - Real_lag_4 1 840491196 1441628909 780.76
## - Expectation_lag_2 1 1216296644 1817434357 790.49
## - Expenditure_lag_1 1 1414812663 2015950377 794.84
summary(final.model)##
## Call:
## lm(formula = Expenditure ~ Expenditure_lag_1 + Expenditure_lag_2 +
## Expenditure_lag_3 + Expenditure_lag_4 + Expenditure_lag_5 +
## Real_lag_1 + Real_lag_2 + Real_lag_4 + Real_lag_5 + Real_lag_6 +
## Expectation_lag_1 + Expectation_lag_2 + Expectation_lag_3 +
## Expectation_lag_5 + Expectation_lag_6 + Interest_lag_1 +
## Interest_lag_3 + Interest_lag_4 + Interest_lag_5 + Interest_lag_6 +
## Rate_lag_1 + Rate_lag_2 + Rate_lag_3 + Rate_lag_6 + Year +
## Month, data = house_sales_main)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8728.9 -1946.8 152.1 1847.6 9105.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.995e+07 4.436e+07 2.253 0.039659 *
## Expenditure_lag_1 8.991e-01 1.513e-01 5.942 2.7e-05 ***
## Expenditure_lag_2 -6.404e-01 2.372e-01 -2.700 0.016446 *
## Expenditure_lag_3 2.690e-01 2.235e-01 1.204 0.247427
## Expenditure_lag_4 -7.711e-01 1.895e-01 -4.069 0.001008 **
## Expenditure_lag_5 -4.302e-01 1.557e-01 -2.762 0.014520 *
## Real_lag_1 -1.362e+03 9.312e+02 -1.463 0.164123
## Real_lag_2 4.916e+03 1.107e+03 4.439 0.000478 ***
## Real_lag_4 -4.442e+03 9.699e+02 -4.580 0.000361 ***
## Real_lag_5 -4.882e+03 1.368e+03 -3.568 0.002805 **
## Real_lag_6 5.086e+03 1.119e+03 4.547 0.000386 ***
## Expectation_lag_1 2.572e+03 7.052e+02 3.648 0.002382 **
## Expectation_lag_2 -3.347e+03 6.076e+02 -5.509 6.0e-05 ***
## Expectation_lag_3 -2.143e+03 8.200e+02 -2.614 0.019563 *
## Expectation_lag_5 2.981e+03 1.045e+03 2.852 0.012128 *
## Expectation_lag_6 -3.060e+03 7.175e+02 -4.265 0.000677 ***
## Interest_lag_1 -1.501e+03 9.891e+02 -1.518 0.149809
## Interest_lag_3 4.453e+03 1.476e+03 3.016 0.008681 **
## Interest_lag_4 -4.501e+03 1.625e+03 -2.769 0.014322 *
## Interest_lag_5 -6.850e+03 1.611e+03 -4.253 0.000695 ***
## Interest_lag_6 1.155e+03 1.142e+03 1.012 0.327651
## Rate_lag_1 2.816e+04 9.828e+03 2.866 0.011786 *
## Rate_lag_2 1.229e+04 1.266e+04 0.971 0.346944
## Rate_lag_3 -3.444e+04 1.140e+04 -3.021 0.008596 **
## Rate_lag_6 2.855e+04 7.374e+03 3.871 0.001507 **
## Year -4.936e+04 2.195e+04 -2.249 0.039989 *
## Month -3.259e+03 2.051e+03 -1.589 0.132887
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6331 on 15 degrees of freedom
## Multiple R-squared: 0.9767, Adjusted R-squared: 0.9362
## F-statistic: 24.14 on 26 and 15 DF, p-value: 3.614e-08
#model
#final.model
pred_df=c(21815,14669,10732,14631,24450,25566,67.16521,64.69312,62.11510,64.90300,65.9866,67.83600,87.92016,84.51865,83.80907,78.85528,79.02186,79.50939,17.7350,17.9850,18.3880,18.1925,15.6750,15.0660,7.628235,7.072365,7.393975,7.721065,8.003324,7.873881,2021,4)
pred_df=transpose(data.frame(pred_df))
colnames(pred_df)=colnames(house_sales_main)[3:length(colnames(house_sales_main))]